#

from flask import Flask, jsonify
from crawl import prdb
from settings import config
from random import choice


__all__ = ['app']


app = Flask(__name__)


@app.route('/')
def index():
    return '<h2>Welcome to Proxy Pool System</h2>'


@app.route('/get-one-proxy')
def one_proxy():
    proxy_list = prdb.zlarges(config['proxy_key'], 10)
    proxy = choice(proxy_list)
    return jsonify(proxy)


if __name__ == "__main__":
    app.run(config['api_host'], config['api_port'])
